<template>
	<view>
		<view class="tabs">
			<u-tabs :list="list2" lineWidth="30" lineColor="#fcaf47"
				itemStyle="padding-left:30rpx;padding-right:-60rpx;width:284rpx; height:80rpx; " @click="click"
				:activeStyle="{
		            color: '#101010 100%',
		            fontWeight: 'bold',
		            transform: 'scale(1.05)',
					
		        }" :inactiveStyle="{
		            color: '#9B9B9B 100%',
		            transform: 'scale(1)'
		        }"></u-tabs>
		</view>
		<view class="bottomCard">
			<act-card_heng v-if="isTabs.name==0"
			v-for="(item,index) in EventDataTO"
			:item="item"
			:imgId="item.img_id"
			:eventname="item.event_name">
				
				</act-card_heng>
			<association-card_heng v-if="isTabs.name==1"
			v-for="(item,index) in Organization"
			:item="item"
			:imgId="item.img_id">
				</association-card_heng>
		</view>
	</view>
</template>

<script>
	import examineCard from '../../components/examineCard.vue'
	import examineCard_association from '../../components/examineCard_association.vue'
	import actCard_examine from '../../components/actCard_examine.vue'
	
	import navTop from '../../components/navTop.vue'
	
	import actCard_heng from '../../components/actCard_heng.vue'
	import associationCard_heng from '../../components/associationCard_heng.vue'
	import {
		mapState,
		mapMutations
	} from 'vuex'

	export default {
		components: {
			navTop,
			examineCard,
			examineCard_association,
			actCard_examine,
			actCard_heng,
			associationCard_heng
		},
		data() {
			return {
				user_Id: this.$store.state.userInfo.id,
				imgUrl: 'https://www.codingyt.com/getImgFast/',
				act_Id: '',
				actData: [],
				isTabs: {
					name: '',
				},
				list2: [{
						name: '活动 ACTIVITY',
					},
					{
						name: '社团 ASSOCIATION',
					},
				],
				navtop: {
					title: 'XXX',
					color: '#000000'
				},
				EventDataTO:[],
				Organization:[],
			}
		},
		methods: {
			click(item) {
				
				this.isTabs.name = item.index;
			},
			getFavoriteEvent(){
				let that=this;
				uni.request({
					url:'https://www.codingyt.com/club/favorite/select',
					data:{
						userId:this.user_Id,
						type:'event'
					},
					success(res) {
						//判断为null
						var tmpData=res.data.data
						for (var i = 0; i < tmpData.length; i++) {
							if(tmpData[i]!=null){
								that.EventDataTO.push(tmpData[i])
							}
						}
						// console.log(that.EventDataTO);
			
					},
				})
			},
			//获取最喜欢的组织
			getFavoriteOrinagztion(){
				let that=this
				uni.request({
					url:'https://www.codingyt.com/club/favorite/select',
					data:{
						userId:this.user_Id,
						type:'organization'
					},
					success(res) {
						//需要一定时间进行加载
						var tmpData=res.data.data
						for (var i = 0; i < tmpData.length; i++) {
							if(tmpData[i]!=null){
								that.Organization.push(tmpData[i])
							}
						}
					},
				})
			},
		},
		onLoad() {
		this.getFavoriteEvent()
		this.getFavoriteOrinagztion()
		},
		created() {
			
		}
	}
</script>

<style scoped lang="scss">
	@import "@/uni_modules/uview-ui/index.scss";

	.tabs {
		margin-top: 1%;
		left: 30rpx;
		color: rgba(16, 16, 16, 100);
		font-size: 48rpx;
		position: relative;
		margin-bottom: 2%;
	}

	.actCard {
		margin-top: 1%;
		left: 0rpx;
		position: relative;
	}
	.buttomcard{
		position: absolute;
		left: -16rpx;
		z-index: 50;
	}
</style>
